package org.easy.baiducensor;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;


@Configuration
@EnableConfigurationProperties({BaiduCensorProperties.class})
@ConditionalOnProperty(prefix = BaiduCensorProperties.PREFIX, name = "enabled", havingValue = "true")
public class BaiduCensorConfiguration {

    @Resource
    private BaiduCensorProperties baiduCensorProperties;

    @Bean
    public BaiduCensorTemplate baiduCensorTemplate() {
        BaiduCensorClient baiduCensorClient = new BaiduCensorClient(baiduCensorProperties.getAppId(), baiduCensorProperties.getApiKey(), baiduCensorProperties.getSecretKey());
        return new BaiduCensorTemplate(baiduCensorClient);
    }


}

